import 'dart:async';

import 'package:date_format/date_format.dart';
import 'package:flutterdemo/utils/date_util.dart';

_testDart() {}

class Demo {
  num count;
  int index;
  Timer _timer;

  //静态不可变更变量
  static const int CODE = 101;

  void demo() {
    int a = 10;
    int b = a > 5 ? a : 0;
    print("三元表达式${a > 5 ?? b}");
    print("除法取商~/:${7 ~/ 2},取值/:${7 / 2},取余%:${7 % 2}");
    register(account: "8772235631");
    Test test = null;
    test?.test();
    print('时间:${DateTime.now()}');
    print('时间:${formatDate(DateTime.now(), [yyyy, mm, dd, HH, nn, ss])}');
    print('时间:${formatDate(DateTime.now(), [
      yyyy,
      '-',
      mm,
      '-',
      dd,
      ' ',
      HH,
      ':',
      nn,
      ':',
      ss
    ])}');
    print('时间:${formatDate(DateTime.now(), [HH, ':', nn, ':', ss])}');
    print('时间:${formatDate(DateTime.parse('2020-07-17 19:40'), [
      yyyy,
      '-',
      mm,
      '-',
      dd,
      ' ',
      HH,
      ':',
      nn,
      ':',
      ss
    ])}');
    var countTime = 0;
    _timer = Timer.periodic(Duration(seconds: 1), (_timer) {

      countTime++;
//      print('countTime=$countTime');
    });
  }

  /// 可选参数
  register({String account, String password, String terminal = "Android"}) {
    print("$account,$password,$terminal");
  }
}

class Test {
  static const int number = 1;

  test() {
    print("【$number】");
  }
}
